package org.evej.apiparser.parser.errorhandling;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

/**
 * Default error handler for Eve Api SAX handlers. Converts all exception to checked ApiHandlerException's.
 */
public class DefaultErrorHandler implements ErrorHandler {

    @Override
    public void warning(SAXParseException e) throws SAXException {
        // ignore warnings
    }

    @Override
    public void error(SAXParseException e) throws SAXException {
        try {
            throw new ApiHandlerExcption(e);
        } catch (ApiHandlerExcption apiHandlerExcption) {
            throw e;
        }
    }

    @Override
    public void fatalError(SAXParseException e) throws SAXException {
        try {
            throw new ApiHandlerExcption(e);
        } catch (ApiHandlerExcption apiHandlerExcption) {
            throw e;
        }
    }
}
